package com.fann;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class ControllerServlet
 */
public class ControllerServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public ControllerServlet() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	/* (non-Javadoc)
	 * @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		String acttype = request.getParameter("acttype");
		HttpSession session = request.getSession();
		
		//(NULL)
		if (acttype == null){
			session.setAttribute("left", "msgPanelTree.jsp");
			session.setAttribute("center", "msgPanel.jsp");
			
		//(classRoom)
		} else if (acttype.equals("classRoom")){
			session.setAttribute("left", "classRoomTree.jsp");
			session.setAttribute("center", "classRoomList.jsp");
			
		} else if (acttype.equals("classRoomList")){
			session.setAttribute("center", "classRoomList.jsp");
			
		} else if (acttype.equals("classRoomAdd")){
			
			session.setAttribute("center", "classRoomEdit.jsp");

		} else if (acttype.equals("classRoomEdit")){
			session.setAttribute("center", "classRoomEdit.jsp");
			
		} else if (acttype.equals("classRoomDelete")){
			session.setAttribute("center", "classRoomDelete.jsp");
			
		//(lessonOpen)
		} else if (acttype.equals("lessonOpen")){
			session.setAttribute("left", "lessonOpenTree.jsp");
			session.setAttribute("center", "lessonOpenList.jsp");
			
		} else if (acttype.equals("lessonOpenList")){
			session.setAttribute("center", "lessonOpenList.jsp");
			
		} else if (acttype.equals("lessonOpenAdd")){
			session.setAttribute("center", "lessonOpenEdit.jsp");
			
		//(join)
		} else if (acttype.equals("join")){
			session.setAttribute("left", "joinTree.jsp");
			session.setAttribute("center", "joinList.jsp");
			
		} else if (acttype.equals("joinList")){
			session.setAttribute("center", "joinList.jsp");
			
		} else if (acttype.equals("joinAdd")){
			session.setAttribute("center", "joinEdit.jsp");
			
		//(msgPanel)
		} else if (acttype.equals("msgPanel")){
			session.setAttribute("left", "msgPanelTree.jsp");
			session.setAttribute("center", "msgPanel.jsp");
			
		} else if (acttype.equals("msgPanelList")){
			session.setAttribute("center", "msgPanel.jsp");

		} else if (acttype.equals("msgPanelAdd")){
			session.setAttribute("center", "editMsg.jsp");
			
		} 
		
		request.getRequestDispatcher("default.jsp").forward(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	}

}
